<!-- 分销中心  -->
<template>
  <s-layout class="index-wrap" title="营销中心" :bgStyle="bgStyle" onShareAppMessage>
    <view class="main">
		<!-- <view class="block">
			
			<view class="ss-flex justify-between">
				<view class="title">
					商家入驻
				</view>
				<view class="font-1" style="color:#003288" @tap="sheep.$router.go('/pages/commission/merchant/submit-log?type=0')">入驻进度</view>
			</view>
			<view class="list">
				<template v-for="(item,index) in list1" :key="index">
					<view class="list-item  ss-flex justify-center" @tap="jump(item)">
						<image style="width:80rpx;height:80rpx" :src="sheep.$url.cdn(item.img)" ></image>
						<view class="name">{{item.name}}</view>
					</view>
				</template>
				
			</view>
		</view> -->
		<view class="block ss-m-t-20">
			<view class="title">
				商务合作
			</view>
			<view class="list">
				<template v-for="(item,index) in list2" :key="index">
					<view class="list-item ss-flex justify-center" @tap="jump(item)" v-if="item.status==1">
						<image style="width:80rpx;height:80rpx" :src="sheep.$url.cdn(item.img)" ></image>
						<view class="name">{{item.name}}</view>
					</view>
				</template>
				<!-- <template >
					<view class="list-item ss-flex justify-center" @tap="openBind" >
						<image style="width:80rpx;height:80rpx" :src="sheep.$url.cdn('/storage/logo/24657e4b73b98fab2834a5c951cd70f.png')" ></image>
						<view class="name">BD编号绑定</view>
					</view>
				</template> -->
			</view>
		</view>
		
		<view class="block ss-m-t-20" v-if="userInfo?.extend?.max_role!='user'">
			<view class="ss-flex justify-between">
				<view class="title">
					代办商户入驻
				</view>
				<view class="font-1" style="color:#003288" @tap="sheep.$router.go('/pages/commission/merchant/submit-log?type=1')">新增/查看代理</view>
			</view>
			<view class="tip ss-flex align-start font-0 ss-m-t-30">
					  <uni-icons type="sound" size="20" color="#E6A406"></uni-icons>
					  <view class="ss-m-l-20">代理商家入驻需开通“商务合作”中的会员。代理商家入驻的越多赚的就越多。</view>
			</view>
			
			<view class="list">
				<template v-for="(item,index) in list3" :key="index">
					<view class="list-item ss-flex justify-center" @tap="jump(item,'isWrite')">
						<image style="width:80rpx;height:80rpx" :src="sheep.$url.cdn(item.img)" ></image>
						<view class="name">{{item.name}}</view>
					</view>
				</template>
			</view>
		</view>
	</view>
	
	
	
	
	
	<su-popup
	  :isMaskClick="false"
	  @close="state.showPop=false"
	  :show="state.showPop"
	  type="center"
	  backgroundColor="#fff"
	  round="10"
	>
	  <view class="pop1 text-center">
	    <view class="ss-m-b-32">输入BD编号</view>
	    <view style="background:#F1F1F1;padding:0 40rpx;width:100%;box-sizing:border-box">
	      <uni-easyinput
	        class="input"
	        :inputBorder="false"
	        v-model="state.bd_code"
	      ></uni-easyinput>
	    </view>
	    <view class="ss-flex justify-center ss-m-t-32">
	      <button
	        @tap=""
	        class="ss-reset-button btn-yao"
	        style="width:214rpx"
	      >
	        确定
	      </button>
	
	    </view>
	  </view>
	</su-popup>
  </s-layout>
</template>

<script setup>
  import sheep from '@/sheep';
  import { onShow,onLoad } from '@dcloudio/uni-app';
  import { computed, reactive,ref } from 'vue';
 

  const state = reactive({
    isWrite:true,
	showPop:false,
	bd_code:''
  });
  
  const list1=[
	  {img:'/storage/giveaway/20250314/d01045188fb2b7c842e568abfd65c02c.png',name:'本地生活',link:'/pages/commission/giveaway/live'},
	  {img:'/storage/giveaway/20250314/568b17cb9162708aa036e9cd1db6eabc.png',name:'电商商城',link:'/pages/commission/giveaway/ebusiness'},
	  // {img:'/storage/logo/24657e4b73b98fab2834a5c951cd70f.png',name:'鲸喜商户',link:'/pages/commission/giveaway/surperise'},
  ]

 const list2 = ref([]);
 // const list2=[
	//   {img:'/storage/giveaway/20250314/574cb95614835d22ce47eed43041a55a.png',name:'商务BD',link:'/pages/commission/giveaway/proxy?type=0'},
	//   {img:'/storage/giveaway/20250314/b1dd1232df93b2964aa239afed5e990a.png',name:'商务BDM',link:'/pages/commission/giveaway/proxy?type=1'},
	//   {img:'/storage/giveaway/20250314/b04d132f3248c5a7061b2e5c166b786d.png',name:'街道服务商',link:'/pages/commission/giveaway/proxy?type=2'},
	//   {img:'/storage/giveaway/20250314/562df550a834422ec2d22d2fae2c0187.png',name:'区县代理',link:'/pages/commission/giveaway/proxy?type=3'},
	//   {img:'/storage/giveaway/20250314/91fa4d67f121f1ec2313fa14c07d9993.png',name:'地市代理',link:'/pages/commission/giveaway/proxy?type=4'},
 //  ]
  const list3=[
  	  {img:'/storage/giveaway/20250314/d01045188fb2b7c842e568abfd65c02c.png',name:'本地生活',link:'/pages/commission/merchant/apply?type=1&shopType=2'},
  	  {img:'/storage/giveaway/20250314/568b17cb9162708aa036e9cd1db6eabc.png',name:'电商商城',link:'/pages/commission/merchant/apply?type=1&shopType=1'},
	  // {img:'/storage/logo/24657e4b73b98fab2834a5c951cd70f.png',name:'鲸囍商户',link:'/pages/commission/merchant/apply?type=1&shopType=3'},
  ]
  
  
  function jump(item,str){
	  // if(str&&!state[str]){
		 //  uni.showToast({
			// title: '请先前往填写资料',
			// icon: 'none',
			// duration: 2000
		 //  })
		 //  return false
	  // }
	  sheep.$router.go(item.link)
	  
	  
  }
  
  async function getInfo(){
  	const res =await sheep.$api.commission.giveaway.getUserInfo()
  	if(!res.data?.name){
		state.isWrite=false
  	}else{
		state.isWrite=true
	}
  	
  }
  
  async function getRoleList(){
	 
  	const res = await sheep.$api.commission.giveaway.roleList()
	
  	list2.value=res.data
  }
  
  const userInfo = computed(() => sheep.$store('user').userInfo);
  
  
  // 绑定编码弹框
  function openBind(){
	 state.showPop=true 
  }
  
  
  
  
  onLoad(()=>{
	  getRoleList();
  })
  
  onShow(() => {
	  getInfo()
	  
  });
</script>

<style lang="scss" scoped>
  :deep(.page-main) {
    background-size: 100% 100% !important;
  }
  .main{
	  padding:20rpx;
	  .block{
		  background:#fff;
		  border-radius: 20rpx;
		  padding:30rpx 20rpx;
		  .tip{
		  	  padding:18rpx 24rpx;
		  	  background:#FFF6EA;
		  	  color:#E6A406;
		  	  line-height: 1.5em;
		  }
		  .title{
			font-size: 32rpx; 
			font-weight: bold;
			color: #383838;
		  }
		  .list{
			  display:grid;
			  grid-template-columns: repeat(4, 1fr);
			  &-item{
				  margin-top:40rpx;
				  flex-direction:column
			  }
			  .name{
				  margin-top:16rpx;
				  font-size:26rpx;
			  }
		  }
	  }
	  
	  
	  
  }
  .pop1 {
    padding: 30rpx 22rpx 18rpx 22rpx;
    font-size: 32rpx;
    width: 600rpx;
    min-height: 176px;
    box-sizing: border-box;
    .my-btn {
      width: 132rpx;
      height: 56rpx;
      border-radius: 20rpx;
      color: #fdfdfd;
      background: #ff9000;
      font-size: 32rpx;
      margin-top: 82rpx;
    }
    .input {
      :deep().uni-easyinput__content-input {
        height: 50rpx;
        font-size: 32rpx;
      }
    }
  }
  .btn-yao {
    width: 130rpx;
    height: 60rpx;
    border-radius: 10rpx;
    background: linear-gradient(295deg, #05d5bf 0%, #06c2ae 50%, #a2cefd 100%);
    font-size: 28rpx;
    color: #fff;
  }
</style>
